package com.easychat.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author 10 2024/10/4
 */
@Getter
@AllArgsConstructor
public enum UserContactTypeEnum {
     USER(0,"U","好友"),
     GROUP(1,"G","群");


     public static UserContactTypeEnum getByName(String name){
          try{
               if(name == null || name.length() ==0){
                    return null;
               }
               return UserContactTypeEnum.valueOf(name.toUpperCase());
          }catch (Exception e){
               return null;
          }
     }
     public static UserContactTypeEnum getByPrefix(String prefix){
          try{
               if(prefix == null || prefix.length() ==0){
                    return null;
               }
               prefix = prefix.substring(0,1);
               for(UserContactTypeEnum typeEnum : UserContactTypeEnum.values()){
                    if(typeEnum.getPrefix().equals(prefix)){
                         return typeEnum;
                    }
               }
               return null;
          }catch (Exception e){
               return null;
          }
     }

     private Integer type;
     private String prefix;
     private String desc;
}
